echo prodtag: $prodtag
echo
echo project: $proj 
echo
echo $files
echo
echo hhs: $hhs

######

timetag=$(date | tr -s ' ' '_' | tr -s ':' '_' | tr -s '.' '_')
echo $timetag

jobdir=$(pwd)
srcdir=/u/xlu/.task/dedx/

rawdir=$srcdir/$proj/fitting_$prodtag\_$timetag/raw/
mkdir -p $rawdir

######

cp $srcdir/dEdxFit.cxx $rawdir/
cp $srcdir/AnadEdxFit.h $rawdir/

cd $rawdir
gomk.sh dEdxFit.cxx
echo
checkSVN.sh | tee svn.log

######

cd $jobdir
pwd
cp $0 ./

ls --color=tty -lht
sleep 5
echo

for ifile in $files
do 
    echo
    echo $ifile
    echo

    for ii in $hhs
    do
        ftag=$(echo ${ifile##*/} | awk -F\. '{printf("%s_h%03d", $1, '$ii')}')
        #echo $ftag

        export outdir=$rawdir/$ftag
        echo $outdir

        job=R${ftag:$( expr ${#ftag} - $len ): $len}
        #echo $job

        cat > $job.sh <<EOF
uname -n
pwd
mkdir -p $outdir
cd $outdir
which aliroot
$rawdir/dEdxFit $ifile $ii > see.log 
EOF
        chmod +x $job.sh
        chmod -w $job.sh

        #echo "not submitting ... but excuting locally!"
        bsub -E $myBIN/preexec.sh -q alice-t3_2h -o oe$job $job.sh
        #./$job.sh

        #qsub -q alice-t3_2h $job.sh 
        #rm -f $job
    done
done

#####################################################################

#set pfName=/home/sgs/test.txt
#${pfName%.*}   = /home/sgs/test
#${pfName##*.} = txt
#${pfName##*/} = test.txt
#${pfName%/*}   = /home/sgs

#-m "lxb474 lxb483 lxb459 lxb462 lxb502 lxb338 lxb553 lxb443 lxb410 lxb387 lxb462 lxb514 lxb303 lxb605 lxb543 lxb459 lxb396 lxb474 lxb355 lxb355 lxb418 lxb354 lxb355 lxb355 lxb618 lxb480 lxb451 lxb545 lxb355 lxb438 lxb476 lxb591 lxb329 lxb568 lxb398 lxb613 lxb591 lxb388 lxb559 lxb299 lxb482 lxb489 lxb462 lxb456 lxb410 lxb451 lxb516 lxb516 lxb468 lxb441 lxb468 lxb515 lxb311 lxb332 lxb516 lxb591 lxb308 lxb313 lxb511 lxb374 lxb476 lxb329 lxb515" \
 